<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>加载中...💤</title>
    <base href="/" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <app-root></app-root>

    <!-- iconfont -->
    <script src="//at.alicdn.com/t/c/font_3387028_dir7xkd3aii.js"></script>

    <script>
      fetch(
        "http://v1.yiketianqi.com/api?unescape=1&vue=1&version=v63&appid=52872973&appsecret=v7mxBDo8"
      )
        .then(function (response) {
          return response.json();
        })
        .then((res) => {
          // 当前时间:
          const nowTime = res.update_time.split(":").at(0);
          // 日出时间:
          const sunriseTime = res.sunrise.split(":").at(0);
          // 日落时间:
          const sunsetTime = res.sunset.split(":").at(0);
          // 早晨天气、晚上天气:
          const wea =
            nowTime <= sunsetTime
              ? (res.wea_day.includes("到") && res.wea_day.split("到").at(1)) ||
                res.wea_day
              : (res.wea_night.includes("到") &&
                  res.wea_night.split("到").at(1)) ||
                res.wea_night;
          // 城市:
          const city = res.city;
          // 星期数
          const weekList = {
            星期一: "痛苦星期一😭",
            星期二: "折磨星期二😒",
            星期三: "混沌星期三🙃",
            星期四: "疯狂星期四🍔",
            星期五: "摸鱼星期五😆",
            星期六: "快乐星期六😍",
            星期日: "无忧星期天🫡",
          };
          const week = weekList[res.week];

          document.title = `${
            new Date().getMonth() + 1 + "." + new Date().getDate()
          }/ ${city}/ ${wea}/ ${res.tem}°C—${week}`;

          // 图标
          const url = `./assets/images/${wea}.png`;
          const link = document.createElement("link");
          link.setAttribute("rel", "icon");
          link.setAttribute("type", "image/x-icon");
          link.setAttribute("href", url);
          document.getElementsByTagName("head")[0].appendChild(link);
        });
    </script>
  </body>
</html>
